#include "bossplane.h"

BossPlane::BossPlane()
{
   m_BossPlane.load(":/resources/dijun2.png");
   //初始化坐标
   m_X=GAME_WIDTH*0.5-m_BossPlane.width()*0.5;
   m_Y=10;
   //初始化矩形板
   m_Rect.setWidth(m_BossPlane.width());
   m_Rect.setHeight(m_BossPlane.height());
   m_Rect.moveTo(m_X,m_Y);
   //发射间隔初始化
   this->m_recorder=0;
   //移动间隔初始化
   m_moverecorder=0;
   //敌机状态
   m_Free  =  true;
   //敌机速度
   m_Speed  =  ENEMY_SPEED;
}

void BossPlane::movenewposition()
{
    if(m_Free)
    {
        return;
    }
    m_moverecorder++;
    if(m_moverecorder<100)
    {
        return;
    }
    m_moverecorder=0;
    m_X  =  rand()  %  (GAME_WIDTH  -  m_Rect.width());
    m_Y  =  rand()  % (200);
    m_Rect.moveTo(m_X,m_Y);
    if(m_boold<0)
    {
        m_Free=true;
    }
}

void BossPlane::shoot()
{
    //记录发射数量
    m_recorder++;
    //判断如果记录数字  未达到发射间隔，直接return
    if(m_recorder>=BULLET_INTERVAL)
    {
        return;
    }
    //到达发射时间处理
    //重置发射时间间隔记录
    m_recorder  =  0;
    //发射子弹
    for(int i=0;i<BULLET_NUM;i++)
    {
        if(m_bullet[i].m_Free)
        {
            m_bullet[i].m_Free=false;
            m_bullet[i].m_X=this->m_X+i*30;
            m_bullet[i].m_Y=this->m_Y  -  25  ;
            break;
        }
    }
}
